<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <input type="text" data-ph="内容">
  <script>
    var input = document.querySelector('input')
    // console.log(input.placeholder)
    var text = input.getAttribute('data-ph')
    if (input.placeholder === void(0)) {
      // 表示该浏览器不支持
      input.value = text
      input.style.color = '#999'
      input.onfocus = function () {
        this.style.color = '#333'
        this.value = ''
      }

      input.onblur = function () {
        if (this.value === "") {
          this.style.color = '#999'
          this.value = text
        }
      }
    }else {
      input.placeholder = text
    }

  
  </script>
</body>
</html>